<?php

namespace app\models;

use think\Model;

/**
 *
 * User: wufeng
 * Date: 2020/02/27
 * @package app\models
 */
class WorkModel extends Model
{
    protected $table = 'edu_work';

	/**
	 * User: wufeng
	 * Date: 2020/02/27
	 *
	 * @param $param
	 * @return array
	 * @throws \think\exception\DbException
	 */
	public function getWorkLists($param)
	{
		$page = isset($param['page']) ? (int) $param['page'] : 1;
		$listRows = isset($param['limit']) ? (int) $param['limit'] : 10;
		$where = [];
		$where['cmdl_id'] =  $param['id'];
		$listData = self::where($where)->order('id asc')
			->paginate($listRows, false, ['page' => $page])
			->toArray();
		if (!empty($listData)) {
			foreach ($listData['data'] as &$item) {
				$item['audio_text'] = 'layui-icon-speaker';
				$item['video_text'] = 'layui-icon-video';
				$item['picture_text'] = 'layui-icon-picture';
			}
		}
		return $listData;
	}
}
